[SUBROUTINE]
version = 1.14
icon = drill.png
name = _("Drill/Reamer Change")
type = drill_chng
help = _("<b>Change Drill and/or settings</b>&#10;Changes setting accordingly even if disabled")
order = act h1 dnum drill d_fra d_met d_num d_let d_usr d_usrg tip h2 tlc spindle_dir cooling h4 v_feed speed h3 dm retract dw dq

[PARAM_ACT]
name = _("Active")
icon = enable.png
type = bool
value = 1
tool_tip = _("Params will be set even if disabled")

[PARAM_H1]
name = _("Select drill or reamer")
type = sub-header

[PARAM_H2]
name = _("Action")
type = sub-header

[PARAM_H3]
name = _("Drilling params")
type = sub-header
;header = h8

[PARAM_H4]
name = _("Feed and speed")
type = sub-header

[PARAM_DNUM]
name = _("Tool number")
header = h1
type = tool
icon = tool.png
tool_tip = _("Select from tool table")
value = 0

[PARAM_DRILL]
name = _("Select drill size")
header = h1
type = combo-user
options = _("User defined=0:Fractional=1:Metric=2:Letter=3:Wire gauge=4:G-Code=5")
value = 1
icon = drill.png
tool_tip = _("Select defined drill or enter size")
links = d_usr=0:d_fra=1:d_met=2:d_let=3:d_num=4:d_usrg=5

[PARAM_D_USR]
name = User defined size
type = float
minimum_value = 0.0
value = 0.375
metric_value = 8.0
hidden = 1
header = h1

[PARAM_D_USRG]
name = User defined size
type = gcode
value = 
hidden = 1
header = h1

[PARAM_D_NUM]
name = _("Wire gauge drill")
header = h1
type = list
options = 1=0.228:2=0.221:3=0.213:4=0.209:5=0.2055:6=0.204:7=0.201:8=0.199:9=0.196:10=0.1935:11=0.191:12=0.189:13=0.185:14=0.182:15=0.18:16=0.177:17=0.173:18=0.1695:19=0.166:20=0.161:21=0.159:22=0.157:23=0.154:24=0.152:25=0.1495:26=0.147:27=0.144:28=0.1405:29=0.136:30=0.1285:31=0.12:32=0.116:33=0.113:34=0.111:35=0.11:36=0.1065:37=0.104:38=0.1015:39=0.0995:40=0.098:41=0.096:42=0.0935:43=0.089:44=0.086:45=0.082:46=0.081:47=0.0785:48=0.076:49=0.073:50=0.07:51=0.067:52=0.0635:53=0.0595:54=0.055:55=0.052:56=0.0465:57=0.043:58=0.042:59=0.041:60=0.04
value = 0.1285
hidden = 1
prefix = #

[PARAM_D_LET]
name = _("Lettered drill")
header = h1
type = list
options = A=0.234:B=0.238:C=0.242:D=0.246:E=0.25:F=0.257:G=0.261:H=0.266:I=0.272:J=0.277:K=0.281:L=0.29:M=0.295:N=0.302:O=0.316:P=0.323:Q=0.332:R=0.339:S=0.348:T=0.358:U=0.368:V=0.377:W=0.386:X=0.397:Y=0.404:Z=0.413
value = 0.257
hidden = 1

[PARAM_D_FRA]
name = _("Fractional drill")
header = h1
type = list
options = 1/64=0.0156:1/32=0.0312:3/64=0.0469:1/16=0.0625:5/64=0.0781:3/32=0.0938:7/64=0.1094:1/8=0.125:9/64=0.1406:5/32=0.1563:11/64=0.1719:3/16=0.1875:13/64=0.2031:7/32=0.2187:15/64=0.2344:1/4=0.25:17/64=0.2656:9/32=0.2812:19/64=0.2969:5/16=0.3125:21/64=0.3281:11/32=0.3438:23/64=0.3594:3/8=0.375:25/64=0.3906:13/32=0.413:27/64=0.4219:7/16=0.4375:29/64=0.4531:15/32=0.4688:31/64=0.4844:1/2=0.5:33/64=0.5156:17/32=0.5312:35/64=0.5469:9/16=0.5625:37/64=0.5781:19/32=0.5938:39/64=0.6094:5/8=0.625:41/64=0.6406:21/32=0.6562:43/64=0.6719:11/16=0.6875:45/64=0.7031:23/32=0.7188:47/64=0.7344:3/4=0.75:49/64=0.7031:25/32=0.7812:51/64=0.7969:13/16=0.8125:53/64=0.8281:27/32=0.8438:55/64=0.8594:7/8=0.875:57/64=0.8906:29/32=0.9062:59/64=0.9219:15/16=0.9375:61/64=0.9531:31/32=0.9688:63/64=0.9844:1=1
value = 0.3125
hidden = 1
suffix = _("inch")

[PARAM_D_MET]
name = _("Metric drill")
header = h1
type = list
options = 1.00=0.0394:1.10=0.0433:1.20=0.0472:1.30=0.0512:1.40=0.0551:1.50=0.0591:1.60=0.063:1.70=0.0669:1.80=0.0709:1.90=0.0748:2.00=0.0787:2.10=0.0827:2.20=0.0866:2.30=0.0906:2.40=0.0945:2.50=0.0984:2.60=0.1024:2.70=0.1063:2.80=0.1102:2.90=0.1142:3.00=0.1181:3.10=0.0220:3.20=0.126:3.30=0.1299:3.40=0.1339:3.50=0.1378:3.60=0.1417:3.70=0.1457:3.80=0.1496:3.90=0.1535:4.00=0.1575:4.10=0.1614:5.00=0.1969:5.10=0.2008:5.20=0.2047:5.30=0.2087:5.40=0.2126:5.50=0.2165:5.60=0.2205:5.70=0.2244:5.80=0.2283:5.90=0.2323:6.00=0.2362:6.10=0.2402:6.20=0.2441:6.30=0.2480:6.40=0.252:6.50=0.2559:6.60=0.2598:6.70=0.2638:6.80=0.2677:6.90=0.2717:7.00=0.2756:7.10=0.2795:7.20=0.2835:7.30=0.2874:7.40=0.2913:7.50=0.2953:7.60=0.2992:7.70=0.3031:7.80=0.3071:7.90=0.311:8.00=0.315:8.10=0.3189:8.20=0.3228:8.30=0.3268:8.40=0.3307:8.50=0.3346:8.60=0.3386:8.70=0.3425:8.80=0.3465:8.90=0.3504:9.00=0.3543:9.10=0.3583:9.20=0.3622:9.30=0.3661:9.40=0.3701:9.50=0.374:9.60=0.378:9.70=0.3819:9.80=0.3858:9.90=0.3898:10.00=0.3937:10.50=0.4134:11.00=0.4331:11.50=0.4528:12.00=0.4724:12.50=0.4921:13.00=0.5118:13.50=0.5315:14.00=0.5512:14.50=0.5709:15.00=0.5906:15.50=0.6102:16.00=0.6299:16.50=0.6496:17.00=0.6693:17.50=0.6890:18.00=0.7087:18.50=0.7283:19.00=0.748:19.50=0.7677:20.00=0.7879:20.50=0.8071:21.00=0.8465:21.50=0.8465:22.00=0.8661:22.50=0.8858:23.00=0.9055:23.50=0.9252:24.00=0.9449:24.50=0.9646:25.00=0.9843
value = 0.2362
hidden = 1
suffix = _("mm")

[PARAM_TLC]
name = _("Use length comp")
icon = comp-l.png
type = combo
options = _("No=0:Already mounted and touched=3:From tool table=1:Table and probe=2")
header = h2
value = 3
tool_tip = _("Use G43 and probe if setup")

[PARAM_COOLING]
name = _("Use cooling")
header = h2
type = combo
options = _("None=9:Flood=8:Mist=7")
icon = snowflake.png
tool_tip = _("Use flood, mist or none")
value = 8

[PARAM_SPEED]
name = _("Spindle speed")
header = h4
type = int
minimum_value = 100
icon = tool-spindle.png
tool_tip = _("Set spindle speed")
value = 2000

[PARAM_TIP]
name = _("Point angle")
type = combo
options = _("118&#176; Medium hard material=118:135&#176; Hard material=135:90&#176; Plastic=90:60&#176; Plastic=60:Flat end=180")
value = 118
tool_tip = _("Drill point angle")
header = h1
icon = drill-point.png

[PARAM_SPINDLE_DIR]
name = _("Start spindle")
header = h2
type = combo
options = _("No=0:Clockwise=3:Counter-clockwise=4")
icon = spindle-start.png
tool_tip = _("Select drill rotation")
value = 3

[PARAM_V_FEED]
name = _("Drilling feed")
header = h4
type = float
icon = tool-vertical-feed.png
tool_tip = _("Plunge or drill feed")
value = 1
not_allowed = 0
metric_value = 25
minimum_value = 0.0

[PARAM_RETRACT]
name = _("Retract (R)")
type = float
icon = drill-retract.png
tool_tip = _("Retract height")
value = 0.02
metric_value = 0.5
header = h3

[PARAM_DM]
name = _("Mode")
type = combo
options = _("Manual=0:With Chip Breaking - G73=73:Standard - G81=81:Dwell at bottom - G82=82:Peck Drilling Cycle - G83=83")
icon = drill-mode.png
tool_tip = _("G73 requires Q>0 and R&#10;G81 requires R&#10;G82 requires R and P&#10;G83 requires Q>0 and R")
value = 81
header = h3

[PARAM_DW]
name = _("Dwell (P)")
type = float
icon = drill-dwell.png
tool_tip = _("Dwell in seconds")
value = 2
header = h3
minimum_value = 0

[PARAM_DQ]
name = _("Delta (Q)")
type = float
minimum_value = 0.001
icon = delta.png
value = 0.2
metric_value = 5
header = h3


[DEFINITIONS]
content =
;	<eval>self.include_once(file name here)</eval>

[CALL]
content =
	(begin #sub_name)
	(drill change params and changing code author : Fernand Veilleux)
	
	#<_drill_feed>       =  #param_v_feed
	#<_drill_retract>    =  #param_retract
	#<_drill_mode>       =  #param_dm
	#<_drill_dwell>      =  #param_dw
	#<_drill_q>          =  #param_dq
	#<_drill_rpm>        =  #param_speed
	#<_spindle_dir>      =  #param_spindle_dir
	#<_cooling_mode>     =  #param_cooling
	
	#<_rpm_normal>       =  #param_speed
	#<_feed_vertical>    =  #param_v_feed
	#<_tool_usage>       =  3
	
	o<select> CALL [31] [#param_drill] [#param_d_usr] [#param_d_fra] [#param_d_met] [#param_d_num] [#param_d_let] [#param_d_usrg]
	#<drill_diameter> = #31
	o<#self_id_metric> if [[#<_metric> EQ 1] AND [#param_drill NE 0]]
		#<drill_diameter> = [#<drill_diameter> * 25.4]
	o<#self_id_metric> endif
	
	#<drill_point_len> = [[#<drill_diameter> / 2] / TAN[#param_tip / 2]]
	(print,Drill info : diameter = #<drill_diameter>, point angle = #param_tip &#176;, point length = #<drill_point_len>)
	
	o<#self_id_tlc> if [[#param_tlc EQ 3] AND [#param_dnum GT 0]]
		M61 Q#param_dnum
	o<#self_id_tlc> endif
	
	o<#self_id_act> if [#param_act AND [#param_dnum NE #5400]]
		M9
		T#param_dnum M6
	o<#self_id_act> endif
	
	o<#self_id_lc> if [[#param_tlc EQ 1] OR [#param_tlc EQ 2]]
		G43 H#param_dnum
	o<#self_id_lc> endif
	
	o<#self_id_01> if [[#<_spindle_dir> GT 0] AND #<_spindle_all_time>]
		o<set_spindle_rpm> CALL [#<_drill_rpm>]
		F#<_drill_feed>
	o<#self_id_01> endif
	(end #sub_name)
